package top.kaoshanji.p2ch06b;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 代码清单 p2ch06b-04：指定Unicode字符使用的书写格式的示例
 * author kaoshanji
 * ^_^
 * create time 2025/1/17 20:03
 */
public class RegexExample04 {

    private static final Logger logger = LogManager.getLogger(RegexExample04.class);

    public static void main(String[] args) {
        logger.info("...代码清单 p2ch06b-04：指定Unicode字符使用的书写格式的示例...");

        String str = "abc你好123";
        Pattern pattern = Pattern.compile("(\\p{script=Han}+)");
        Matcher matcher = pattern.matcher(str);
        if (matcher.find()) {
            String hans = matcher.group(1);
            logger.info("...hans:{}...", hans);
        }


    }

}
